if test (uname -s) = Darwin
    if test (uname -m) = arm64
        if test -x /opt/homebrew/bin/brew
            eval (/opt/homebrew/bin/brew shellenv)
            export HOMEBREW_API_DOMAIN="https://mirrors.ustc.edu.cn/homebrew-bottles/api"
            export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.ustc.edu.cn/brew.git"
            export HOMEBREW_CORE_GIT_REMOTE="https://mirrors.ustc.edu.cn/homebrew-core.git"
            export HOMEBREW_BOTTLE_DOMAIN="https://mirrors.ustc.edu.cn/homebrew-bottles"
        end
    end

    if type -q hs
        function switch_to_english
            hs -c 'hs.keycodes.currentSourceID("com.apple.keylayout.ABC")' 1>/dev/null 2>&1
        end

        function switch_to_english_precmd --on-event fish_preexec
            switch_to_english
        end
    else if type -q macism
        function switch_to_english
            macism com.apple.keylayout.ABC
        end

        function switch_to_english_precmd --on-event fish_preexec
            switch_to_english
        end
    end
end
